<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
	<%@include file="/common/common.jsp"%>
<%@page import="com.eos.system.utility.StringUtil"%>
<%@page import="com.eos.access.http.security.config.HttpSecurityConfig"%>
<%@page import="com.primeton.cap.AppUserManager"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): glenn
  - Date: 2016-05-12 08:48:01-
  - Description:
-->
<head>
<%
   String contextPath=request.getContextPath();
   String url = null;
   HttpSecurityConfig securityConfig = new HttpSecurityConfig();
   boolean isOpenSecurity = securityConfig.isOpenSecurity();
   if(isOpenSecurity){
   		boolean isAllInHttps = securityConfig.isAllInHttps();
   		if(!isAllInHttps){
   			String ip = securityConfig.getHost();
   			String https_port = securityConfig.getHttps_port();
   			url = "https://" + ip + ":" + https_port + contextPath + "/coframe/auth/login/org.gocom.components.coframe.auth.login.login.flow";
   		}else{
   			url = "org.gocom.components.coframe.auth.login.login.flow"; 
   		}
   }else{
   		url = "org.gocom.components.coframe.auth.login.login.flow";
   }
  
   
 %>
 <%
	String original_url=null;
	Object objAttr=request.getAttribute("original_url");
	if(objAttr != null){
		original_url=StringUtil.htmlFilter((String)objAttr);
	}
 %>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>
</title>
	<script src="<%= request.getContextPath() %>/coframe/tools/layui/layui.js" type="text/javascript"></script>
    <link rel="stylesheet" href="<%= request.getContextPath() %>/coframe/tools/layui/css/layui.css">
    
    <!-- 登录界面CSS -->
	 <link rel="stylesheet" href="<%= request.getContextPath() %>/coframe/auth/login/css/login.css">

<script language="javascript"> 

function addCssByStyle(cssString){
	var doc=document;
	var style=doc.createElement("style");
	style.setAttribute("type", "text/css");

	if(style.styleSheet){// IE
		style.styleSheet.cssText = cssString;
	} else {// w3c
		var cssText = doc.createTextNode(cssString);
		style.appendChild(cssText);
	}

	var heads = doc.getElementsByTagName("head");
	if(heads.length) {
		heads[0].appendChild(style);
	} else {
		doc.documentElement.appendChild(style);
	}
}

//alert( window.navigator.userAgent+"%%%"+jQuery.client.version +"%%%"+jQuery.client.browser+"%%%"+$.client.os+"&&&&&"+jQuery.client.getOsVersion())

</script> 
<!-- 字体设置，win7、vista系统使用雅黑字体,其他系统使用宋体 End -->

<!--[if IE 6]>
	<script type='text/javascript' src='/wui/common/jquery/plugin/8a-min.js'></script>
<![endif]-->

<!--超时跳转,跳出iframe黄宝2011/5/25-->
<script type="text/javascript">
  if(top.location != self.location) top.location=self.location;
</script> 


<script type="text/javascript">
$(document).ready(function() {
    $(function() {
        
		//alert($("label.overlabel").length)
		$("label.overlabel").overlabel();

        var iconImg="<%=request.getContextPath() %>/web/resource/sfyoalogin/wui/images/graypoint.png"
        var iconImg_over="<%=request.getContextPath() %>/web/resource/sfyoalogin/wui/images/redpoint1.png"
    
        $('#slideshow').cycle({
            fx:      'scrollHorz',
            timeout:  7000,
            prev:    '#crossPrev',
            next:    '#crossNext', 
            pager:   '#nav',
            pagerAnchorBuilder: pagerFactory,
            before:  function(currSlideElement, nextSlideElement, options, forwardFlag) {  
			        	if($.browser.msie){
							if($.browser.version=="6.0") {
								DD_belatedPNG.fix('a,div,img,background,span');
							}
						}
			

                        var curIndex=$(currSlideElement).attr("index");
                        var curSlidnavtitle=$($("#slideDemo .slidnavtitle")[curIndex]);
                        if(curSlidnavtitle!=null){
                            curSlidnavtitle.css("background","url('"+iconImg+"') center center no-repeat");
                           // curSlidnavtitle.css("zindex",9999999);
                        }
    
                        var nextIndex=$(nextSlideElement).attr("index");
    
                        var nextSlidnavtitle=$($("#slideDemo .slidnavtitle")[nextIndex]);
                        if(nextSlidnavtitle!=null){
                            var tesy = "url('"+iconImg_over+"') no-repeat";
                            var tempInt = parseInt(nextIndex)  + 1;
                            nextSlidnavtitle.css("background","url('<%=request.getContextPath() %>/web/resource/sfyoalogin/wui/images/redpoint" + tempInt + ".png') center center  no-repeat");
                            //nextSlidnavtitle.css("zindex",999);
                        }
                    }                       
        }); 
        function pagerFactory(idx, slide) {
            var s = idx > 20 ? ' style="display:none"' : '';
            //alert((idx==0?iconImg_over:iconImg)
            return ' <span class="m-t-5  slidnavtitle hand"  style="background:url('+(idx==0?iconImg_over:iconImg)+') center center no-repeat;position:relative;height:32px;width:32px;z-index:99999">&nbsp;</span>';
        };
        
        $("#login").bind("mouseover", function() {
            $(this).removeClass("lgsm");
            $(this).addClass("lgsmMouseOver");
        });
        $("#login").bind("mouseout", function() {
            $(this).removeClass("lgsmMouseOver");
            $(this).addClass("lgsm");
        });
        
        $(".crossNav a").hover(function() {
            $(this).css("background-position", "0 -29px");
        }, function() {
            $(this).css("background-position", "0 0px");
        });
        
        //检测微软雅黑字体在客户端是否安装
        //fontDetection("sfclsid", $("input[name='fontName']").val());
        //检测用户当前浏览器及其版本
        ieVersionDetection();
        setRandomBg();
    });
    //焦点设置
    //$("input[name='loginid']").focus();
    //----------------------------------
    // form表单提交时check
    //----------------------------------
    
});


function setRandomBg() {
    var imgArray=new Array();
    var imgPath="";
    
    var discnt = 0;
    
    if(discnt==0){ //系统默认图片
       imgArray=new Array("lg_bg1.jpg","lg_bg2.jpg","lg_bg3.jpg","lg_bg4.jpg","lg_bg5.jpg","lg_bg6.jpg");
       discnt=6;
       imgPath="<%=request.getContextPath() %>/web/resource/sfyoalogin/wui/images/";
    }else          //用户自定义图片
       imgPath="/LoginTemplateFile/";
        
    var i = Math.floor(Math.random()*discnt);
    var j = Math.floor(Math.random()*discnt);
    var k = Math.floor(Math.random()*discnt);
    
    var img1="",img2="",img3="";
    if(discnt>3){
	    while (i >= discnt ) {
	        i = Math.floor(Math.random()*discnt);
	    }
	    while (j >= discnt || j == i) {
	        j = Math.floor(Math.random()*discnt);
	    }
	    while (k >= discnt || k == i || k == j) {
	        k = Math.floor(Math.random()*discnt);
	    }
	    img1=imgArray[i];
        img2=imgArray[j];
        img3=imgArray[k];
    }else if(discnt==3){
        img1=imgArray[0];
        img2=imgArray[1];
        img3=imgArray[2];
    }else if(discnt==2){
        img1=imgArray[0];
        img2=imgArray[1];
    }else if(discnt==1){
        img1=imgArray[0];
    }
    
    if(discnt>=3){
	    $("#disimg0").css("background", "url(" +imgPath+img1+ ") no-repeat");
	    $("#disimg1").css("background", "url(" +imgPath+img2+ ") no-repeat");
	    $("#disimg2").css("background", "url(" +imgPath+img3+ ") no-repeat");
    }else if(discnt==2){
        $("#disimg0").css("background", "url(" +imgPath+img1+ ") no-repeat");
	    $("#disimg1").css("background", "url(" +imgPath+img2+ ") no-repeat");
    }else if(discnt==1){
        $("#disimg0").css("background", "url(" +imgPath+img1+ ") no-repeat");
    }
}

function ieVersionDetection() {
    if(navigator.userAgent.indexOf("MSIE")>0){ //是否是IE浏览器 
        if(navigator.userAgent.indexOf("MSIE 6.0") > 0){ //6.0
            $("#ieverTips").show();
            return;
        } 
    }
    $("#ieverTips").hide();
}

function fontDetection(objectId, fontName) {
    //加载系统字体
    getSFOfStr(objectId);

    if(!isExistOTF(fontName)) {
        $("#fontTips").show();
    } else {
        $("#fontTips").hide();
    }
}

//---------------------------------------------
// System font detection.  START
//---------------------------------------------
/**
 * detection system font exists.
 * @param fontName font name
 * @return true  :Exist.
 *         false :Does not Exist
 */
function isExistOTF(fontName) {
    if (fontName == undefined 
            || fontName == null 
            || fontName.trim() == '') {
        return false;
    }
    
    if (sysfonts.indexOf(";" + fontName + ";") != -1) {
        return true;
    }
    return false;
};

/**
 * getting to the system font string.
 * @param objectId object's id
 * @return system font string.
 */
function getSFOfStr(objectId) {
    var sysFontsArray = new Array();
    sysFontsArray = getSystemFonts(objectId);
    for(var i=0; i<sysFontsArray.length; i++) {
        sysfonts += sysFontsArray[i];
        sysfonts += ';'
    }
}
//-------------------------------------------
// Save the system font string, 
// used for multiple testing.
//-------------------------------------------
var sysfonts = ';';

/**
 * getting to the system font list
 *
 * @param objectId The id of components of the system font.
 * @return fonts list
 */
function getSystemFonts(objectId) {
    var a = document.all(objectId).fonts.count;
    var fArray = new Array();
    for (var i = 1; i <= document.all(objectId).fonts.count; i++) {
        fArray[i] = document.all(objectId).fonts(i)
    }
    return fArray
}

/**
 * Returns a string, with leading and trailing whitespace
 * omitted.
 * @return  A this string with leading and trailing white
 *          space removed, or this string if it has no leading or
 *          trailing white space.
 */
String.prototype.trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

//---------------------------------------------
// System font detection.  END
//---------------------------------------------
</script>

<STYLE TYPE="text/css">
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td,select{        
    font-size:12px;
}


body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td,select{        
    font-size:11px;
    /*font-family:"微软雅黑","宋体"!important;*/ 
}
/*For slide*/
.slideDivContinar { height: 260px; width: 920px; padding:0; margin:0; overflow: hidden }
.slideDiv {height:260px; width: 920px;top:0; left:0;margin:0;padding:0;}
label.overlabel {
	position:absolute;
	top:9px;
	left:4px;
	z-index:1;
	color:#999;
	width:90px;
	line-height: 24px;
	padding-left: 4px;
}

/*For Input*/
.inputforloginbg{ width:172px;height:21px;border:none;}
.inputforloginbg input{border:none;height:15px;background:none;}

.lgsm {width:300px;height:35px;background:#5F5142; border:none;text-align: center;color: #fff;font-size: 16px;letter-spacing: 2px;}
.lgsmMouseOver {width:300px;height:35px;background:#8B7761; border:none;text-align: center;color: #fff;font-size: 16px;letter-spacing: 2px;}

.lgen {width:300px;height:35px;background:#5F5142; border:none;text-align: center;color: #fff;font-size: 16px;letter-spacing: 2px;}
.lgenMouseOver {width:300px;height:35px;background:#8B7761; border:none;text-align: center;color: #fff;font-size: 16px;letter-spacing: 2px;}


.crossNav{width:100%;height:30px;position:absolute;margin-top:105px;padding-left:30px;padding-right:30px;}


.input_out{
	height:42px;
	width:300px;
	background:url('<%=request.getContextPath() %>/web/resource/sfyoalogin/wui/images/Inputbox_bg.png') repeat;
	margin-top: 1px;
	position: relative;
}
#for_userpassword{left:-30px;}
#for_loginid{left:-25px;}
.input_inner{
	height:32px;
	line-height:32px;
	width:250px;
	margin-left:5px;
	margin-top:5px;
	border:0px solid red;
	font-size:12px;
	outline: none;
	background:none;
	float: left;
}
.inputicon{width: 24px;height: 24px;float: right;margin-top: 10px;margin-right: 10px;}
.inputtable td{background: #DBD2BA;}

html,body{
	padding: 0px;
	margin: 0px;
}

.topmenu{display: inline-block;float:left;width: 80px;line-height: 40px;font-size: 14px;font-weight: bold;margin-left: 10px;text-decoration: none;text-align: center;color: #605040;}

.datalist{width:100%;height:90px;margin: 0px auto;overflow: hidden;line-height: 28px;}
.datalink{text-decoration: none;color: #74675A !important;display: block;font-size: 12px;border-bottom: 1px #F5E6C6 dashed;padding: 0px;}



	#form1{
	    height: 300px;
	}
</STYLE>
</head>
<body style="padding:0;margin:0;margin:0;padding:0;background-image: url(<%=request.getContextPath()%>/coframe/auth/images/index30.jpg);background-size: 100% 800px;background-repeat: no-repeat;" scroll="auto">
<TABLE width="100%" height="100%" cellpadding="0px" cellspacing="0px">
    <TR>
        <TD align="center" valign="top">
            <table width="100%" cellpadding="0px" cellspacing="0px">
                <TR>
                    <TD width="*">&nbsp;</TD>
                    <TD valign="top" id="lgcontenttbl" style="width:100px">
                        <form name="loginForm"  method="post" onsubmit="return login();" action="<%=url%>">
                            <INPUT type="hidden" name="logintype" value="1">
                            <input type="hidden" name="fontName" value="微软雅黑">
                            <input type=hidden name="message" value="">
                            <input type=hidden name="gopage" value="">
				            <input type=hidden name="formmethod" value="post">
				            <INPUT type=hidden name="rnd" >
                            <INPUT type=hidden name="serial"> 
                            <INPUT type=hidden name="username">
                            <input type="hidden" name="isie" id="isie">
                            
                            <div style="width: 1000px;height: auto;margin: 0px auto;overflow: hidden;" align="center" >
                               	<div >
                            		<div id="logintxt" style="text-align: center;line-height: 70px;color: #fff;font-size: 16px;font-weight: bold;letter-spacing: 2px;"></div>
                               			
                            		<div id="form1" >
	                             		<div class="col-lg-6">
										    <label>帐号</label>
										      <input type="text" class="form-control" id="firstname" name="userId" placeholder="请输入帐号">
										       <p id="error" class="login-error"></p>
										  </div>
										  <div class="col-lg-6">
										    <label>密码</label>
										      <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码">
										      <p id="error2" class="login-error"></p>
										  </div>
										  <div class="col-lg-6">
										      <button type="submit" class="btn"  name="submit" id="login" style="background-color: #4fa0d8;border-color: #4fa0d8;">登录</button>
										       <p id="error3" class="login-error"></p>
										  </div>
                               	</div>
                               	</div>
                            </div>
                        </form>
                    </TD>
                    <TD width="*">&nbsp;</TD>
                </TR>
            </TABLE>
        </TD>
    </TR>
</TABLE>

<!--detection the system font start -->
<DIV style="LEFT: 0px; POSITION: absolute; TOP: 0px;"><OBJECT ID="sfclsid" CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" WIDTH="0px" HEIGHT="0px"></OBJECT></DIV>
 
<script type="text/javascript">
     
     nui.parse();
     var form = new nui.Form("#form1");
     
     //移动光标 减少样式错误率
     //document.getElementById('userpassword').focus();
     //document.getElementById('for_loginid').focus();
     
     
     //nui.get("userId").focus();
     // $('#userId').focus();
     
     function onCheckUserId(e){
       if (e.isValid) {
         if(e.value==""){
           e.errorText = "用户名不能为空";
           e.isValid = false;
         }
       }
     }
     
     function onCheckPassword(e){
       if (e.isValid) {
         if(e.value==""){
           e.errorText = "密码不能为空";
           e.isValid = false;
         }
       }
     }
    
	  
	
      //获取键盘 Enter 键事件并响应登录
     function keyboardLogin(e){
       login();
     }
     function login(){
        // debugger;
     	var form = new nui.Form("#form1");
        form.validate();
        if (form.isValid() == false) 
        	return false;
        document.loginForm.submit();
     }
      function showError(msg){
 	    //debugger;
      	 $("#error").html(msg);
      }
      
     <% 
     	Object result = request.getAttribute("result");
     	String userName = (String)request.getAttribute("userId");
     	String errStr = null;
     	if (userName==null)userName="";
     	String password = (String)request.getAttribute("password");
     	if (password==null)password="";
     	if(result != null){
     		Integer resultCode = (Integer)result;
     		System.out.println(resultCode);
     		
     		 if(resultCode == 0){
     		 	//errStr="密码错误！";
     		 	  //out.println("<script>alert('hhh')</script>"); 
     		 	 // out.println("alert('hhh');");
		     	out.println("showError('密码错误！');");
		     	
		        
		     	//out.println(" $(\"#loginErr\").html('密码错误！');");
		     }else if(resultCode == -1){
		     	//errStr="用户不存在！";
		     	out.println("showError('用户不存在！');");
		     	//out.println("document.getElementById('loginErr').innerHTML='用户不存在！';");
		     	//out.println(" $(\"#loginErr\").html('用户不存在！');");
		     }else if(resultCode == -2){
		     	//errStr="用户无权限登录，请联系系统管理员！";
		     	out.println("showError('用户无权限登录，请联系系统管理员！');");
		     	//out.println("document.getElementById('loginErr').innerHTML='用户无权限登录，请联系系统管理员！';");
		     	//out.println(" $(\"#loginErr\").html('用户无权限登录，请联系系统管理员！');");
		     }else if(resultCode == 3){
		     	//errStr="用户已过期！";
		     	out.println("showError('用户已过期！');");
		     	//out.println("document.getElementById('loginErr').innerHTML='用户已过期！';");
		     	//out.println(" $(\"#loginErr\").html('用户已过期！');");
		     }else if(resultCode == 4){
		     	//errStr="用户未到开始使用时间！";
		     	out.println("showError('用户未到开始使用时间！');");
		     	//out.println("document.getElementById('loginErr').innerHTML='用户未到开始使用时间！';");
		     	//out.println(" $(\"#loginErr\").html('用户未到开始使用时间！');");
		     }else if(resultCode == 5){
		     	//errStr="密码已过期！";
		     	out.println("showError('密码已过期！');");
		     	//out.println("document.getElementById('loginErr').innerHTML='密码已过期！';");
		     	//out.println(" $(\"#loginErr\").html('密码已过期！');");
		     }else if(resultCode == -3){
		     	//errStr="查询用户信息失败，请联系系统管理员检查数据库连接！";
      			out.println("showError('查询用户信息失败，请联系系统管理员检查数据库连接！');");
      			//out.println("document.getElementById('loginErr').innerHTML='查询用户信息失败，请联系系统管理员检查数据库连接！';");
      			//out.println(" $(\"#loginErr\").html('查询用户信息失败，请联系系统管理员检查数据库连接！');");
     		 }else{
     		 	//errStr="未知的异常，请联系系统管理员！";
      			out.println("showError('未知的异常，请联系系统管理员！');");
      			//out.println("document.getElementById('loginErr').innerHTML='未知的异常，请联系系统管理员！';");
      			//out.println(" $(\"#loginErr\").html('未知的异常，请联系系统管理员！');");
     		 }
     	}
     	
	  %>
    
</script>
  <script language="javascript"> 
  
if(navigator.appName == "Microsoft Internet Explorer") { 

   if( navigator.userAgent.indexOf("MSIE 8.0")>0 || ( navigator.userAgent.indexOf("MSIE 9.0")>0)){

     alert("当前使用的IE浏览器版本过低，建议使用IE 10以上版本或者谷歌，火狐浏览器进行访问");
   }
}



</script> 
</body> 
</html>



